package com.example.park2212.house

import android.view.View
import android.widget.ImageView
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.lib_base.entity.MyHourseBean
import com.example.park2212.R

class HourseAreaAdapter(vm:HoursViewModel):BaseQuickAdapter<MyHourseBean,BaseViewHolder>(R.layout.item_earahouse) {
    val houseItemAdapter by lazy { HouseItemAdapter(vm) }
    lateinit var vm:HoursViewModel
    init {
        this.vm = vm
    }
    override fun convert(helper: BaseViewHolder, item: MyHourseBean) {
        helper.setText(R.id.tv01,"${item.dong}栋")
        helper.setText(R.id.hourse_area,"${item.area}m²")

        houseItemAdapter.addData(item.list)
        val rv = helper.getView<RecyclerView>(R.id.rv_01)
        rv.apply {
            adapter = houseItemAdapter
            layoutManager = LinearLayoutManager(context,RecyclerView.HORIZONTAL,false)
        }


        helper.getView<ImageView>(R.id.more01).apply {
            setOnClickListener {
            if (rv.visibility == View.GONE){
                rv.visibility = View.VISIBLE
                setImageResource(R.drawable.ic_aaa_down)
            }else{
                rv.visibility = View.GONE
                setImageResource(R.drawable.ic_aaa_up)
            }
          }
        }



    }
}